package com.xinzhi.controller;


import com.xinzhi.pojo.dto.Certificate;
import com.xinzhi.pojo.dto.Massage;
import com.xinzhi.service.IRealNameAuthenticationService;
import com.xinzhi.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class RealNameAuthenticationController {
    @Autowired
    private IRealNameAuthenticationService realNameAuthenticationService;

    /**
     * 实名认证
     * @param certificate 用户名和身份证号
     * @return
     */
    @PostMapping("/verification")
    public Result verification(@RequestBody Certificate certificate){
        return realNameAuthenticationService.authenticate(certificate);
    }

    /**
     * 返回实名信息
     * @param certificate 用户名和身份证号
     * @return
     */
    @PostMapping("/message")
    public Result message(@RequestBody Certificate certificate){
        return realNameAuthenticationService.authenticate2(certificate);
    }

    /**
     * 添加用户实名绑卡信息
     * @param massage 实名绑卡信息
     * @return
     */
    @PostMapping("/updateUser")
    public Result updateUser(@RequestBody Massage massage){
        return realNameAuthenticationService.addUser(massage);
    }

    /**
     * 删除缓存
     * @param phone 手机号
     */
    @GetMapping("/deleteUser")
    public void deleteUser(String phone){
        realNameAuthenticationService.deleteRedis(phone);
    }
}
